<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="UTF-8" />
    <meta http-equiv="X-UA-Compatible" content="IE=edge" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <title>私有属性</title>
  </head>
  <body>
    <script>
      class Person {
        name; // 公有属性
        #age; // 私有属性
        #sex;
        constructor(name, age, sex) {
          this.name = name;
          this.#age = age;
          this.#sex = sex;
        }

        introduce() {
          console.log(this.name, this.#age, this.#sex);
        }
      }

      const p = new Person("徐懋增", 28, "男");
      console.log(p);

    //   console.log(p.#age);
      p.introduce();
    </script>
  </body>
</html>
